package com.heima;

import io.minio.MinioClient;
import io.minio.PutObjectArgs;

import java.io.FileInputStream;

public class Main {
    public static void main(String[] args) {


        FileInputStream fileInputStream = null;
        try {

            fileInputStream = new FileInputStream("/Users/yangqing/Desktop/temp/test.html");



            MinioClient minioClient = MinioClient.builder().credentials("minioadmin", "minioadmin")
                    .endpoint("http://127.0.0.1:9000")
//                    .endpoint("http://127.0.0.2:9090")
                    .build();

            //2.上传
            PutObjectArgs putObjectArgs = PutObjectArgs.builder()
                    .object("test.html")//文件名
                    .contentType("text/html")//文件类型
                    .bucket("leadnews")//桶名词  与minio创建的名词一致
                    .stream(fileInputStream, fileInputStream.available(), -1) //文件流
                    .build();
            minioClient.putObject(putObjectArgs);
        } catch (Exception ex) {
            ex.printStackTrace();
        }

    }
}